<?php
namespace Index\Controller;
use Think\Controller;
class CategoryController extends CommonController {
	public function indexAction(){

		$cid = I('get.cid',0);

		$sql = "select count(id) count from category_question where cid='{$cid}'";

		$count = current(M()->query($sql))['count'];
		//实例化index控制器类，调用index控制器里的问题列表模板
		$obj = new IndexController();
		// 使用index控制器里的indexAction方法，拼了一条sql语句，括号里的参数就是$where，从数据库取出分类条数，比如问题里有几条是属于php分类下面的，展示在页面上
		// $sql = "select t1.*,t2.username from question t1 left join user t2 on t1 .uid=t2.id LEFT JOIN category_question t3 on t1.id=t3.qid where t3.cid='{$cid}' limit {$Page->firstRow},{$Page->listRows}";
        $obj->indexAction("LEFT JOIN category_question t3 on t1.id=t3.qid where t3.cid='{$cid}'",$count);
		 
	}
}